#include <iostream>
#include <vector>
#include <string>
#include <deque>
#include <algorithm>

using namespace std;

class Person{
public:
    Person(string name)
    : _score(0)
      ,_name(name){}

    void setScore(int);
    int showScore();
    string showName();

private:
    int _score;
    string _name;
};

void Person::setScore(int score){
    this->_score = score;

    return;
}

int Person::showScore(){
    return this->_score;
}

string Person::showName(){
    return this->_name;
}

void displayScore(deque<int> deque){
    for(auto i : deque){
        cout << i << "  ";
    }
    cout << endl;
}

void getScore(Person & student){
    deque<int> scoreDeque;
    for(int i = 0; i < 10; ++i){
        scoreDeque.push_back(rand()%101);
    }
    sort(scoreDeque.begin(), scoreDeque.end());

    cout << "before cut" << endl;
    displayScore(scoreDeque);
    scoreDeque.pop_front();
    scoreDeque.pop_back();
    cout << "after cut" << endl;
    displayScore(scoreDeque);

    student.setScore([] (deque<int> averageScore) { 
        int tempScore = 0;
        for(auto i : averageScore){
            tempScore += i;
        }

        cout << tempScore/(averageScore.size()) << endl; 
        return tempScore/(averageScore.size()); 
    }(scoreDeque));
}

void test1(){
    vector<Person> personList;
    personList.push_back(Person("Mike"));
    personList.push_back(Person("June"));
    personList.push_back(Person("Josephe"));
    personList.push_back(Person("JOKER"));
    personList.push_back(Person("Ketherine"));

    for(auto i = personList.begin(); i != personList.end(); i++){
        getScore(*i);
    }

    for(auto i : personList){
        cout << i.showName() << ": " << i.showScore() << endl;
    }
}

int main()
{
    srand(time_t(NULL));
    
    test1();
    return 0;
}

